
package xj.graph2d.app.diagram;

import xj.graph2d.Document;
import xj.graph2d.DrawShape;
import xj.graph2d.DrawShapeBase;
import xj.graph2d.DrawShapeConstants;
import xj.graph2d.DrawShapeFactory;
import xj.graph2d.GraphEdgeBase;
import xj.graph2d.GraphNodeBase;
import xj.graph2d.app.DrawApp;
import xj.graph2d.layout.ActivityDiagramLayout;
import xj.model.uml.ActivityNode;

public class ActivityDiagramBuilder 
  extends DiagramBuilder { 

  public ActivityDiagramBuilder(DrawApp main, String name) {
    super(main, name, Document.DocumentType.UML_Activity_Diagram);

    diagram.setGraphLayoutManager(new ActivityDiagramLayout(diagram));    
  }

  public static GraphNodeBase makeActivityNodeShape(String name, 
						    ActivityNode.ActivityType type) { 
    String tempname = "UMLActivityDiagram.Action"; 
    switch (type) {
    case Computation:
      tempname = "UMLActivityDiagram.Action"; 
      break;
    case Object:
      tempname = "UMLActivityDiagram.Object1"; 
      break;
    case DataStore: 
      tempname = "UMLActivityDiagram.DataStore"; 
      break;
    case Decision:
      tempname = "UMLActivityDiagram.Decision"; 
      break;
    case Merge:
      tempname = "UMLActivityDiagram.MergeNode"; 
      break;
    case Fork:
      tempname = "UMLActivityDiagram.ForkNode"; 
      break;
    case Join: 
      tempname = "UMLActivityDiagram.JoinNode"; 
      break;
    case Initial: 
      tempname = "UMLActivityDiagram.InitialNode"; 
      break;
    case Final:
      tempname = "UMLActivityDiagram.FinalNode"; 
      break;
    case Terminate: 
      tempname = "UMLActivityDiagram.FinalFlow"; 
      break;
    case Accept_Event: 
      tempname = "UMLActivityDiagram.AcceptEvent1"; 
      break;
    case Send_Event:
      tempname = "UMLActivityDiagram.SendEvent"; 
      break;
    }
    GraphNodeBase node = (GraphNodeBase) makeShape(tempname);
    if (name != null) { 
      node.setLabelString(name);
    }
    return node; 
  }

  public static GraphEdgeBase makeFlowShape() { 
    String tempname = "UMLActivityDiagram.Flow1"; 
    GraphEdgeBase edge = (GraphEdgeBase) makeShape(tempname); 
    return edge;
  }
						    
}